<?php include ROOT . '/views/layouts/header.php'; ?>

    <section>
        <div class="container">
            <div class="row">
                <div class="col-sm-9 padding-right">
                    <h2 class="font-semibold text-xl text-center">Корзина</h2>
                    <p class="m-1">Вы выбрали такие товары:</p>
                    <div class="grid grid-cols-5 gap-2 mx-2">
                        <?php if ($productsInCart): ?>
                        <div class="border-r-2 border-black">Артикул Товара</div>
                        <div class="border border-black">Название</div>
                        <div class="border border-black">Стомость, $</div>
                        <div class="border border-black">Количество, шт</div>
                        <div class="border border-black">Удалить</div>
                        <?php foreach ($products as $product): ?>
                            <div class="border border-black"><?php echo $product['id']; ?></div>
                            <div class="border border-black">
                                <a href="/product/<?php echo $product['id']; ?>">
                                    <?php echo $product['name']; ?>
                                </a>
                            </div>
                            <div class="border border-black"><?php echo $product['price']; ?></div>
                            <div class="border border-black"><?php echo $productsInCart[$product['id']]; ?></div>
                            <div class="border border-black">
                                <a href="/cart/delete/<?php echo $product['id']; ?>">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        <?php endforeach; ?>
                    </div>
                    <div class="grid grid-cols-2 m-2">
                        <div class="border border-black"><a class="btn btn-default checkout" href="/cart/checkout"><i
                                        class="fa fa-shopping-cart"></i> Оформить заказ</a></div>
                        <div class="border border-black">Общая стоимость, $: <?php echo $totalPrice; ?></div>
                    </div>
                    <span>
                    <a href="/cart/clear">Очистка корзинычёя</a>
                </span>
                    <?php else: ?>
                        <p>Корзина пуста</p>

                        <a class="btn btn-default checkout" href="/"><i class="fa fa-shopping-cart"></i> Вернуться к
                            покупкам</a>
                    <?php endif; ?>

                </div>
            </div>
        </div>
    </section>

<?php include ROOT . '/views/layouts/footer.php'; ?>